package com.scujcc.diandiantv;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class ChannelRvAdapter extends RecyclerView.Adapter<ChannelRvAdapter.ChannelRowHolder> {
    @NonNull
    @Override
    public ChannelRowHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.channel_rv, parent, false);
        ChannelRowHolder row = new ChannelRowHolder(view);
        return row;
    }

    @Override
    public void onBindViewHolder(@NonNull ChannelRowHolder holder, int position) {
        //TODO 此处暂时硬编码为固定内容
        holder.bind("中央一台 综合频道");
    }

    @Override
    public int getItemCount() {
        //TODO 此处暂时硬编码为10行
        return 10;
    }

    public class ChannelRowHolder extends RecyclerView.ViewHolder {
        private TextView title;

        public ChannelRowHolder(@NonNull View row) {
            super(row);
            this.title = row.findViewById(R.id.channel_title);
        }

        public void bind(String title) {
            this.title.setText(title);
        }
    }
}
